A class is a template for objects, and an object is an instance of a class.
When the individual objects are created, they inherit all the variables and methods from the class.
Classes and objects are the two main aspects of object-oriented programming.
Create a Class
To create a class, use the keyword class
Create an Object
In Java, an object is created from a class.
We have already created the class named Main, so now we can use this to create objects.
To create an object of Main, specify the class name, followed by the object name, and use the keyword new.
We can create multiple objects for a single class
We can also create objects in different class.
Compile both of them and run the file in which object is created.
Accessing Class Attributes:-